import createEditor from './editor'
import background from './bg.jpg'
import './global.css'

let editor = createEditor()
document.body.appendChild(editor)

const img = new Image()
img.src = background
document.body.appendChild(img)

// 处理 js 模块的热替换
module.hot.accept('./editor', () => {
  console.log('editor 模块更新了，需要在这里手动处理热替换逻辑')
  let value = editor.innerHTML
  document.body.removeChild(editor)
  let newEditor = createEditor()
  newEditor.innerHTML = value
  document.body.appendChild(newEditor)
  editor = newEditor
})

// 处理图片资源的热替换
module.hot.accept('./bg.jpg', () => {
  img.src = background
})
